/**
 * 
 */
package com.java.test.system.dto;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import org.springframework.jdbc.core.RowMapper;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author 系统日志
 *
 */
public class LogInfo implements RowMapper<LogInfo> {

	// 主键
	private int id;

	// 账号
	private String account;

	// ip地址
	private String ipAddress;

	// 创建时间
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime createTime;

	// 操作内容
	private String content;

	
	
	public LogInfo() {
		super();
	}

	public LogInfo(String account, String ipAddress, LocalDateTime createTime, String content) {
		super();
		this.account = account;
		this.ipAddress = ipAddress;
		this.createTime = createTime;
		this.content = content;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public LocalDateTime getCreateTime() {
		return createTime;
	}

	public void setCreateTime(LocalDateTime createTime) {
		this.createTime = createTime;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Override
	public LogInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
		LogInfo info = new LogInfo();

		info.setId(rs.getInt("id"));

		info.setAccount(rs.getString("account"));

		info.setContent(rs.getString("content"));

		info.setCreateTime(rs.getTimestamp("create_time") == null ? null
				: rs.getTimestamp("create_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());

		info.setIpAddress(rs.getString("ip_address"));

		return info;
	}

}
